﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;
using System.ComponentModel;

namespace LIK.NetAssemblyChecker
{


    internal abstract class AssemblyObject
    {

        #region Local Properties
        protected int _intImageIndex;
        protected string _strFullFilePath;
        string _strName;
        #endregion

        #region Internal Properties
        internal AssemblyObject Parent { get; set; }

        internal string Name
        {
            get { return _strName; }
        }

        internal string FilePath
        {
            get { return _strFullFilePath; }
        }
        #endregion

        #region Constructor

        protected AssemblyObject(string file, AssemblyObject parent)
            : this(file, -1, parent)
        {
        }

        protected AssemblyObject(string file, int imageIndex, AssemblyObject parent)
        {
            _strFullFilePath = file;
            Parent = parent;
            if (_strFullFilePath.Length > 0)
                _strName = Path.GetFileName(_strFullFilePath);
            if (imageIndex < 0)
            {
                string ext = Path.GetExtension(_strFullFilePath).ToLower();
                if (ext == ".exe")
                    _intImageIndex = (int)Commons.FileObjectIcon.ExeFile;
                else if (ext == ".dll")
                    _intImageIndex = (int)Commons.FileObjectIcon.DllFile;
            }
            else
            {
                _intImageIndex = imageIndex;
            }
        }

        #endregion

        #region Methods

        internal string GetFolder()
        {
            return Path.GetDirectoryName(_strFullFilePath);
        }

         protected  virtual TreeNode GetTreeNode(string nodeName, object tag)
        {
            TreeNode tr = new TreeNode(nodeName);
            tr.ImageIndex = _intImageIndex;
            tr.SelectedImageIndex = _intImageIndex;
            tr.StateImageIndex = _intImageIndex;
            tr.Tag = tag;
            return tr;
        }

        #endregion


    }



}
